<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="vb,">










<meta name="description" content="介绍 基于 udp 开发 使用 vb 开发 仅支持点对点对话，不支持多人，不是聊天室 支持来消息提醒功能 支持发送对话表情 支持发送文件（TCP） VB 编程练手 TCP 和 UDP 本人和老婆认识时做的 2 人聊天工具（公司不能上网） TCP/IP Winsock 状态表示(0) sckClosed：关闭状态(1) sckOpen：打开状态(2) sckListening：侦听状态(3) sck">
<meta name="keywords" content="vb">
<meta property="og:type" content="article">
<meta property="og:title" content="VB聊天工具">
<meta property="og:url" content="http://www.soshare.cn/2012/06/12/120612-vb-chat/index.html">
<meta property="og:site_name" content="soshare">
<meta property="og:description" content="介绍 基于 udp 开发 使用 vb 开发 仅支持点对点对话，不支持多人，不是聊天室 支持来消息提醒功能 支持发送对话表情 支持发送文件（TCP） VB 编程练手 TCP 和 UDP 本人和老婆认识时做的 2 人聊天工具（公司不能上网） TCP/IP Winsock 状态表示(0) sckClosed：关闭状态(1) sckOpen：打开状态(2) sckListening：侦听状态(3) sck">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2019-10-13T08:40:24.008Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="VB聊天工具">
<meta name="twitter:description" content="介绍 基于 udp 开发 使用 vb 开发 仅支持点对点对话，不支持多人，不是聊天室 支持来消息提醒功能 支持发送对话表情 支持发送文件（TCP） VB 编程练手 TCP 和 UDP 本人和老婆认识时做的 2 人聊天工具（公司不能上网） TCP/IP Winsock 状态表示(0) sckClosed：关闭状态(1) sckOpen：打开状态(2) sckListening：侦听状态(3) sck">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"right","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://www.soshare.cn/2012/06/12/120612-vb-chat/">



<script data-ad-client="ca-pub-3578624407535320" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>


  <title>VB聊天工具 | soshare</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-right page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">soshare</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">分享</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-file">
          <a href="http://taosha126.ys168.com" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-file"></i> <br>
            
            File
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br>
            
            Commonweal 404
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            Search
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="Searching..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>


 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://www.soshare.cn/2012/06/12/120612-vb-chat/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="tosobright">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="soshare">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">VB聊天工具</h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2012-06-12T00:00:00+08:00">
                2012-06-12
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Program/" itemprop="url" rel="index">
                    <span itemprop="name">Program</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2012/06/12/120612-vb-chat/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2012/06/12/120612-vb-chat/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/2012/06/12/120612-vb-chat/" class="leancloud_visitors" data-flag-title="VB聊天工具">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">Visitors&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h1><ul>
<li>基于 udp 开发</li>
<li>使用 vb 开发</li>
<li>仅支持点对点对话，不支持多人，不是聊天室</li>
<li>支持来消息提醒功能</li>
<li>支持发送对话表情</li>
<li>支持发送文件（TCP）</li>
<li>VB 编程练手 TCP 和 UDP</li>
<li>本人和老婆认识时做的 2 人聊天工具（公司不能上网）</li>
<li>TCP/IP Winsock 状态表示<br>(0) sckClosed：关闭状态<br>(1) sckOpen：打开状态<br>(2) sckListening：侦听状态<br>(3) sckConnectionPending：连接状态<br>(4) sckResolvingHost：解析主机中<br>(5) sckHostResolved：已解析主机<br>(6) sckConnecting：正在连接<br>(7) sckConnected：已经连接<br>(8) sckClosing：客户端正在关闭<br>(9) sckError：连接发生错误</li>
</ul>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><figure class="highlight vb"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br><span class="line">491</span><br><span class="line">492</span><br><span class="line">493</span><br><span class="line">494</span><br><span class="line">495</span><br><span class="line">496</span><br><span class="line">497</span><br><span class="line">498</span><br><span class="line">499</span><br><span class="line">500</span><br><span class="line">501</span><br><span class="line">502</span><br><span class="line">503</span><br><span class="line">504</span><br><span class="line">505</span><br><span class="line">506</span><br><span class="line">507</span><br><span class="line">508</span><br><span class="line">509</span><br><span class="line">510</span><br><span class="line">511</span><br><span class="line">512</span><br><span class="line">513</span><br><span class="line">514</span><br><span class="line">515</span><br><span class="line">516</span><br><span class="line">517</span><br><span class="line">518</span><br><span class="line">519</span><br><span class="line">520</span><br><span class="line">521</span><br><span class="line">522</span><br><span class="line">523</span><br><span class="line">524</span><br><span class="line">525</span><br><span class="line">526</span><br><span class="line">527</span><br><span class="line">528</span><br><span class="line">529</span><br><span class="line">530</span><br><span class="line">531</span><br><span class="line">532</span><br><span class="line">533</span><br><span class="line">534</span><br><span class="line">535</span><br><span class="line">536</span><br><span class="line">537</span><br><span class="line">538</span><br><span class="line">539</span><br><span class="line">540</span><br><span class="line">541</span><br><span class="line">542</span><br><span class="line">543</span><br><span class="line">544</span><br><span class="line">545</span><br><span class="line">546</span><br><span class="line">547</span><br><span class="line">548</span><br><span class="line">549</span><br><span class="line">550</span><br><span class="line">551</span><br><span class="line">552</span><br><span class="line">553</span><br><span class="line">554</span><br><span class="line">555</span><br><span class="line">556</span><br><span class="line">557</span><br><span class="line">558</span><br><span class="line">559</span><br><span class="line">560</span><br><span class="line">561</span><br><span class="line">562</span><br><span class="line">563</span><br><span class="line">564</span><br><span class="line">565</span><br><span class="line">566</span><br><span class="line">567</span><br><span class="line">568</span><br><span class="line">569</span><br><span class="line">570</span><br><span class="line">571</span><br><span class="line">572</span><br><span class="line">573</span><br><span class="line">574</span><br><span class="line">575</span><br><span class="line">576</span><br><span class="line">577</span><br><span class="line">578</span><br><span class="line">579</span><br><span class="line">580</span><br><span class="line">581</span><br><span class="line">582</span><br><span class="line">583</span><br><span class="line">584</span><br><span class="line">585</span><br><span class="line">586</span><br><span class="line">587</span><br><span class="line">588</span><br><span class="line">589</span><br><span class="line">590</span><br><span class="line">591</span><br><span class="line">592</span><br><span class="line">593</span><br><span class="line">594</span><br><span class="line">595</span><br><span class="line">596</span><br><span class="line">597</span><br><span class="line">598</span><br><span class="line">599</span><br><span class="line">600</span><br><span class="line">601</span><br><span class="line">602</span><br><span class="line">603</span><br><span class="line">604</span><br><span class="line">605</span><br><span class="line">606</span><br><span class="line">607</span><br><span class="line">608</span><br><span class="line">609</span><br><span class="line">610</span><br><span class="line">611</span><br><span class="line">612</span><br><span class="line">613</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">Option</span> <span class="keyword">Explicit</span></span><br><span class="line"><span class="keyword">Const</span> REG_SZ = <span class="number">1</span></span><br><span class="line"><span class="keyword">Const</span> HKEY_LOCAL_MACHINE = &amp;H80000002</span><br><span class="line"><span class="keyword">Const</span> WM_LBUTTONDOWN = &amp;H201</span><br><span class="line"></span><br><span class="line"><span class="comment">'API定义</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Declare</span> <span class="keyword">Function</span> RegOpenKey <span class="keyword">Lib</span> <span class="string">"advapi32.dll"</span> <span class="keyword">Alias</span> <span class="string">"RegOpenKeyA"</span> (<span class="keyword">ByVal</span> hKey <span class="keyword">As</span> <span class="built_in">Long</span>, <span class="keyword">ByVal</span> lpSubKey <span class="keyword">As</span> <span class="built_in">String</span>, phkResult <span class="keyword">As</span> <span class="built_in">Long</span>) <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Declare</span> <span class="keyword">Function</span> RegQueryValueEx <span class="keyword">Lib</span> <span class="string">"advapi32.dll"</span> <span class="keyword">Alias</span> <span class="string">"RegQueryValueExA"</span> (<span class="keyword">ByVal</span> hKey <span class="keyword">As</span> <span class="built_in">Long</span>, <span class="keyword">ByVal</span> lpValueName <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> lpReserved <span class="keyword">As</span> <span class="built_in">Long</span>, lpType <span class="keyword">As</span> <span class="built_in">Long</span>, lpData <span class="keyword">As</span> Any, lpcbData <span class="keyword">As</span> <span class="built_in">Long</span>) <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Declare</span> <span class="keyword">Function</span> FlashWindow <span class="keyword">Lib</span> <span class="string">"User32"</span> (<span class="keyword">ByVal</span> hWnd <span class="keyword">As</span> <span class="built_in">Long</span>, <span class="keyword">ByVal</span> bInvert <span class="keyword">As</span> <span class="built_in">Long</span>) <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Declare</span> <span class="keyword">Function</span> GetForegroundWindow <span class="keyword">Lib</span> <span class="string">"User32"</span> () <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Declare</span> <span class="keyword">Function</span> GetSystemDefaultLCID <span class="keyword">Lib</span> <span class="string">"kernel32"</span> () <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="comment">'定义变量</span></span><br><span class="line"><span class="keyword">Dim</span> info_ip <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> info_name <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> connect <span class="keyword">As</span> <span class="built_in">Boolean</span></span><br><span class="line"><span class="keyword">Dim</span> localid <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> a <span class="keyword">As</span> <span class="built_in">Boolean</span></span><br><span class="line"><span class="keyword">Dim</span> font_name, font_size, font_underline, font_strikethru, font_bold, font_italic, font_color</span><br><span class="line"><span class="keyword">Dim</span> onaccept <span class="keyword">As</span> <span class="built_in">Boolean</span></span><br><span class="line"><span class="keyword">Dim</span> onsend <span class="keyword">As</span> <span class="built_in">Boolean</span></span><br><span class="line"><span class="keyword">Dim</span> FileNumber <span class="keyword">As</span> <span class="built_in">Integer</span></span><br><span class="line"><span class="keyword">Dim</span> client_LenFile <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> client_ProBarLen <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> client_VarPlus <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> GetFileNum <span class="keyword">As</span> <span class="built_in">Integer</span></span><br><span class="line"><span class="keyword">Dim</span> server_LenFile <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> server_ProBarLen <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> server_VarPlus <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> client_Error(<span class="keyword">ByVal</span> Number <span class="keyword">As</span> <span class="built_in">Integer</span>, Description <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> Scode <span class="keyword">As</span> <span class="built_in">Long</span>, <span class="keyword">ByVal</span> Source <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> HelpFile <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> HelpContext <span class="keyword">As</span> <span class="built_in">Long</span>, CancelDisplay <span class="keyword">As</span> <span class="built_in">Boolean</span>)</span><br><span class="line">    client.Close</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> server_Error(<span class="keyword">ByVal</span> Number <span class="keyword">As</span> <span class="built_in">Integer</span>, Description <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> Scode <span class="keyword">As</span> <span class="built_in">Long</span>, <span class="keyword">ByVal</span> Source <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> HelpFile <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> HelpContext <span class="keyword">As</span> <span class="built_in">Long</span>, CancelDisplay <span class="keyword">As</span> <span class="built_in">Boolean</span>)</span><br><span class="line">    server.Close</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> fileclient_Error(<span class="keyword">ByVal</span> Number <span class="keyword">As</span> <span class="built_in">Integer</span>, Description <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> Scode <span class="keyword">As</span> <span class="built_in">Long</span>, <span class="keyword">ByVal</span> Source <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> HelpFile <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> HelpContext <span class="keyword">As</span> <span class="built_in">Long</span>, CancelDisplay <span class="keyword">As</span> <span class="built_in">Boolean</span>)</span><br><span class="line">    fileclient.Close</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> fileserver_Error(<span class="keyword">ByVal</span> Number <span class="keyword">As</span> <span class="built_in">Integer</span>, Description <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> Scode <span class="keyword">As</span> <span class="built_in">Long</span>, <span class="keyword">ByVal</span> Source <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> HelpFile <span class="keyword">As</span> <span class="built_in">String</span>, <span class="keyword">ByVal</span> HelpContext <span class="keyword">As</span> <span class="built_in">Long</span>, CancelDisplay <span class="keyword">As</span> <span class="built_in">Boolean</span>)</span><br><span class="line">    fileserver.Close</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Form_Load()</span><br><span class="line"><span class="keyword">Dim</span> FPath <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> fontpath <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> skinpath <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> skin <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> hKey <span class="keyword">As</span> <span class="built_in">Long</span>, ret <span class="keyword">As</span> <span class="built_in">Long</span>, lenData <span class="keyword">As</span> <span class="built_in">Long</span>, typeData <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> Name <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> S <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line">    onaccept = <span class="literal">False</span></span><br><span class="line">    onsend = <span class="literal">False</span></span><br><span class="line">    SendLabel.Caption = <span class="string">"Up:NaN"</span></span><br><span class="line">    ReceiveLabel.Caption = <span class="string">"Down:NaN"</span></span><br><span class="line">    <span class="keyword">Me</span>.Caption = <span class="string">"For"</span></span><br><span class="line">    <span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">Resume</span> <span class="keyword">Next</span></span><br><span class="line">    <span class="comment">'设置加载位置至屏幕中心</span></span><br><span class="line">    <span class="keyword">Me</span>.Left = (Screen.Width - <span class="keyword">Me</span>.Width) / <span class="number">2</span></span><br><span class="line">    <span class="keyword">Me</span>.Top = (Screen.Height - <span class="keyword">Me</span>.Height) / <span class="number">2</span></span><br><span class="line">    <span class="comment">'加载皮肤</span></span><br><span class="line">    skinpath = App.path &amp; <span class="string">"\Data\skin.ini"</span></span><br><span class="line">    Open skinpath <span class="keyword">For</span> Input <span class="keyword">As</span> <span class="meta">#1</span></span><br><span class="line">    Input <span class="meta">#1, skin</span></span><br><span class="line">    Close <span class="meta">#1</span></span><br><span class="line">    Skin1.LoadSkin skin</span><br><span class="line">    Skin1.ApplySkin <span class="keyword">Me</span>.hWnd</span><br><span class="line">    <span class="comment">'调用自动调整控件大小模块</span></span><br><span class="line">    <span class="keyword">Call</span> ResizeInit(<span class="keyword">Me</span>)</span><br><span class="line">    <span class="comment">'图片缓存区域RTF</span></span><br><span class="line">    Richtemp.TextRTF = <span class="string">""</span></span><br><span class="line">    <span class="comment">'系统默认字体，S为显示系统默认的字体</span></span><br><span class="line">    <span class="keyword">If</span> lang = <span class="string">"chs"</span> <span class="keyword">Or</span> lang = <span class="string">"cht"</span> <span class="keyword">Then</span></span><br><span class="line">        Name = <span class="string">"GUIFont.Facename"</span></span><br><span class="line">        ret = RegOpenKey(HKEY_LOCAL_MACHINE, <span class="string">"SOFTWARE\Microsoft\Windows NT\CurrentVersion\GRE_Initialize"</span>, hKey)</span><br><span class="line">        <span class="keyword">If</span> ret = <span class="number">0</span> <span class="keyword">Then</span></span><br><span class="line">            ret = RegQueryValueEx(hKey, Name, <span class="number">0</span>, typeData, <span class="keyword">ByVal</span> vbNullString, lenData) <span class="comment">'注意ByVal千万别忘了</span></span><br><span class="line">        <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">        S = <span class="built_in">String</span>(lenData, Chr(<span class="number">0</span>))</span><br><span class="line">        ret = RegQueryValueEx(hKey, Name, <span class="number">0</span>, typeData, <span class="keyword">ByVal</span> S, lenData) <span class="comment">'注意ByVal千万别忘了</span></span><br><span class="line">        S = Left(S, InStr(S, Chr(<span class="number">0</span>)) - <span class="number">1</span>)</span><br><span class="line">        <span class="comment">'设置文本框的字体</span></span><br><span class="line">        record.Font = S</span><br><span class="line">        msg.Font = S</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    FPath = App.path &amp; <span class="string">"\Data\info.ini"</span></span><br><span class="line">    fontpath = App.path &amp; <span class="string">"\Data\font.ini"</span></span><br><span class="line">    <span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">GoTo</span> errhandle</span><br><span class="line">    <span class="comment">'个人信息</span></span><br><span class="line">    <span class="keyword">If</span> Dir(FPath) = <span class="string">""</span> <span class="keyword">Then</span></span><br><span class="line">        Open FPath <span class="keyword">For</span> Output <span class="keyword">As</span> <span class="meta">#1</span></span><br><span class="line">        Write <span class="meta">#1, "127.0.0.1", "juan"</span></span><br><span class="line">        Close <span class="meta">#1</span></span><br><span class="line">        remoteip.<span class="keyword">Text</span> = <span class="string">"127.0.0.1"</span></span><br><span class="line">        nickname.<span class="keyword">Text</span> = <span class="string">"juan"</span></span><br><span class="line">    <span class="keyword">Else</span></span><br><span class="line">        Open FPath <span class="keyword">For</span> Input <span class="keyword">As</span> <span class="meta">#1</span></span><br><span class="line">        Input <span class="meta">#1, info_ip, info_name</span></span><br><span class="line">        Close <span class="meta">#1</span></span><br><span class="line">        remoteip.<span class="keyword">Text</span> = info_ip</span><br><span class="line">        nickname.<span class="keyword">Text</span> = info_name</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="comment">'字体信息</span></span><br><span class="line">    <span class="keyword">If</span> Dir(fontpath) &lt;&gt; <span class="string">""</span> <span class="keyword">Then</span></span><br><span class="line">        Open fontpath <span class="keyword">For</span> Input <span class="keyword">As</span> <span class="meta">#1</span></span><br><span class="line">        Input <span class="meta">#1, font_name, font_size, font_underline, font_strikethru, font_bold, font_italic, font_color</span></span><br><span class="line">        Close <span class="meta">#1</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    record.Font.Size = font_size</span><br><span class="line">    msg.Font.Size = font_size</span><br><span class="line">    <span class="comment">'信息文本清空</span></span><br><span class="line">    record.<span class="keyword">Text</span> = <span class="string">""</span></span><br><span class="line">    msg.<span class="keyword">Text</span> = <span class="string">""</span></span><br><span class="line">    <span class="keyword">With</span> StatusBar</span><br><span class="line">        .Panels(<span class="number">1</span>).<span class="keyword">Text</span> = <span class="string">"Local IP:"</span> + server.LocalIP</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line">    <span class="comment">'打开监听端口</span></span><br><span class="line">    <span class="keyword">Call</span> setport</span><br><span class="line">    <span class="keyword">Exit</span> <span class="keyword">Sub</span></span><br><span class="line">errhandle:</span><br><span class="line">    MsgBox <span class="string">"load_Err:"</span> + Err.Description</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Public</span> <span class="keyword">Function</span> lang() <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line">    localid = GetSystemDefaultLCID</span><br><span class="line">    <span class="keyword">Select</span> <span class="keyword">Case</span> localid</span><br><span class="line">        <span class="keyword">Case</span> &amp;H404 <span class="comment">'繁体语言</span></span><br><span class="line">            lang = <span class="string">"cht"</span></span><br><span class="line">        <span class="keyword">Case</span> &amp;H804 <span class="comment">'简体语言</span></span><br><span class="line">            lang = <span class="string">"chs"</span></span><br><span class="line">        <span class="keyword">Case</span> &amp;H409 <span class="comment">'English</span></span><br><span class="line">            lang = <span class="string">"en"</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">Select</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Function</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'设置client and server端口</span></span><br><span class="line"><span class="keyword">Sub</span> setport()</span><br><span class="line"><span class="keyword">With</span> server</span><br><span class="line">    .LocalPort = <span class="number">40000</span></span><br><span class="line">    .Listen</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line"><span class="keyword">With</span> client</span><br><span class="line">    .LocalPort = <span class="number">40001</span></span><br><span class="line">    .RemotePort = <span class="number">40000</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line"><span class="keyword">With</span> fileserver</span><br><span class="line">    .LocalPort = <span class="number">40002</span></span><br><span class="line">    .Listen</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line"><span class="keyword">With</span> fileclient</span><br><span class="line">    .LocalPort = <span class="number">40003</span></span><br><span class="line">    .RemotePort = <span class="number">40002</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Sub</span> clientconnect()</span><br><span class="line"><span class="keyword">With</span> client</span><br><span class="line">    .Close</span><br><span class="line">    .RemoteHost = remoteip.<span class="keyword">Text</span></span><br><span class="line">    .connect</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Sub</span> fileclientconnect()</span><br><span class="line"><span class="keyword">With</span> fileclient</span><br><span class="line">    .Close</span><br><span class="line">    .RemoteHost = remoteip.<span class="keyword">Text</span></span><br><span class="line">    .connect</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Form_Activate()</span><br><span class="line">    remoteip.SetFocus</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'界面大小重置</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Form_Resize()</span><br><span class="line">    <span class="keyword">Call</span> ResizeForm(<span class="keyword">Me</span>)</span><br><span class="line">    <span class="keyword">If</span> <span class="keyword">Me</span>.WindowState = <span class="number">0</span> <span class="keyword">Then</span></span><br><span class="line">        StatusBar.Panels(<span class="number">1</span>).Width = <span class="keyword">Me</span>.ScaleWidth * <span class="number">0.5</span></span><br><span class="line">        StatusBar.Panels(<span class="number">2</span>).Width = <span class="keyword">Me</span>.ScaleWidth * <span class="number">0.5</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'界面卸载</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Form_Unload(Cancel <span class="keyword">As</span> <span class="built_in">Integer</span>)</span><br><span class="line">    server.Close</span><br><span class="line">    client.Close</span><br><span class="line">    fileserver.Close</span><br><span class="line">    fileclient.Close</span><br><span class="line">    <span class="keyword">Call</span> TrayRemoveIcon</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'字体</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Font_Click()</span><br><span class="line"><span class="keyword">Dim</span> FPath <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">Resume</span> <span class="keyword">Next</span></span><br><span class="line">    CommonDialog1.CancelError = <span class="literal">True</span></span><br><span class="line">    CommonDialog1.Flags = cdlCFBoth <span class="keyword">Or</span> cdlCFEffects</span><br><span class="line">    CommonDialog1.ShowFont</span><br><span class="line">    <span class="keyword">If</span> Err = cdlCancel <span class="keyword">Then</span></span><br><span class="line">        <span class="keyword">Exit</span> <span class="keyword">Sub</span> <span class="comment">'对话框取消退出</span></span><br><span class="line">    <span class="keyword">Else</span></span><br><span class="line">        font_name = CommonDialog1.FontName</span><br><span class="line">        font_size = CommonDialog1.FontSize</span><br><span class="line">        font_underline = CommonDialog1.FontUnderline</span><br><span class="line">        font_strikethru = CommonDialog1.FontStrikethru</span><br><span class="line">        font_bold = CommonDialog1.FontBold</span><br><span class="line">        font_italic = CommonDialog1.FontItalic</span><br><span class="line">        font_color = CommonDialog1.Color</span><br><span class="line">        <span class="comment">'保存字体信息</span></span><br><span class="line">        <span class="keyword">If</span> CommonDialog1.Action = <span class="number">0</span> <span class="keyword">Then</span></span><br><span class="line">            FPath = App.path &amp; <span class="string">"\Data\font.ini"</span></span><br><span class="line">            Open FPath <span class="keyword">For</span> Output <span class="keyword">As</span> <span class="meta">#1</span></span><br><span class="line">            Write <span class="meta">#1, font_name, font_size, font_underline, font_strikethru, font_bold, font_italic, font_color</span></span><br><span class="line">            Close <span class="meta">#1</span></span><br><span class="line">        <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> min_Click()</span><br><span class="line"><span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">Resume</span> <span class="keyword">Next</span></span><br><span class="line">    <span class="keyword">Call</span> TrayAddIcon(<span class="keyword">Me</span>, Picture1, <span class="string">"For juan"</span>, NIIF_ICON_MASK)</span><br><span class="line">    <span class="keyword">If</span> min.Value = <span class="number">1</span> <span class="keyword">Then</span></span><br><span class="line">        <span class="keyword">Me</span>.Visible = <span class="literal">False</span> <span class="comment">'让程序界面不可见</span></span><br><span class="line">        <span class="keyword">Call</span> TrayIcon(Picture1(<span class="number">1</span>).Picture)</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Form_MouseMove(Button <span class="keyword">As</span> <span class="built_in">Integer</span>, Shift <span class="keyword">As</span> <span class="built_in">Integer</span>, x <span class="keyword">As</span> <span class="built_in">Single</span>, y <span class="keyword">As</span> <span class="built_in">Single</span>)</span><br><span class="line"><span class="keyword">Static</span> Message <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">Resume</span> <span class="keyword">Next</span></span><br><span class="line"><span class="comment">'x   is   the   current   mouse   location   along   the   x-axis</span></span><br><span class="line">Message = x / Screen.TwipsPerPixelX</span><br><span class="line"><span class="keyword">If</span> <span class="keyword">Me</span>.Visible = <span class="literal">False</span> <span class="keyword">Then</span></span><br><span class="line"><span class="keyword">Select</span> <span class="keyword">Case</span> Message</span><br><span class="line"><span class="comment">'   Left   double   click</span></span><br><span class="line"><span class="keyword">Case</span> WM_LBUTTONDOWN</span><br><span class="line">    min.Value = <span class="number">0</span></span><br><span class="line">    <span class="keyword">Me</span>.Visible = <span class="literal">True</span></span><br><span class="line">    <span class="keyword">If</span> newmsgTimer.Enabled = <span class="literal">True</span> <span class="keyword">Then</span></span><br><span class="line">    newmsgTimer.Enabled = <span class="literal">False</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">Call</span> TrayRemoveIcon</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Select</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'托盘图标闪烁</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> newmsgTimer_Timer()</span><br><span class="line">    a = <span class="keyword">Not</span> a</span><br><span class="line">    <span class="keyword">If</span> a = <span class="literal">True</span> <span class="keyword">Then</span></span><br><span class="line">        <span class="keyword">Call</span> TrayIcon(Picture1(<span class="number">0</span>).Picture)</span><br><span class="line">    <span class="keyword">Else</span></span><br><span class="line">        <span class="keyword">Call</span> TrayIcon(Picture1(<span class="number">1</span>).Picture)</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'client向server请求连接</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Request_Click()</span><br><span class="line"><span class="keyword">Dim</span> FPath <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line">    connect = <span class="literal">True</span></span><br><span class="line">    FPath = App.path &amp; <span class="string">"\Data\info.ini"</span></span><br><span class="line">    <span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">GoTo</span> errhandle</span><br><span class="line">    <span class="keyword">Call</span> clientconnect  <span class="comment">'文本信息连接</span></span><br><span class="line">    <span class="keyword">Call</span> fileclientconnect <span class="comment">'文件发送连接</span></span><br><span class="line">    <span class="keyword">If</span> info_ip &lt;&gt; remoteip.<span class="keyword">Text</span> <span class="keyword">Or</span> info_name &lt;&gt; nickname.<span class="keyword">Text</span> <span class="keyword">Then</span></span><br><span class="line">        Open FPath <span class="keyword">For</span> Output <span class="keyword">As</span> <span class="meta">#1</span></span><br><span class="line">        Write <span class="meta">#1, remoteip.Text, nickname.Text</span></span><br><span class="line">        Close <span class="meta">#1</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    msg.SetFocus</span><br><span class="line">    <span class="keyword">Exit</span> <span class="keyword">Sub</span></span><br><span class="line">errhandle:</span><br><span class="line">    MsgBox <span class="string">"request_connect_Err:"</span> + Err.Description</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'server连接请求</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> server_ConnectionRequest(<span class="keyword">ByVal</span> requestID <span class="keyword">As</span> <span class="built_in">Long</span>)</span><br><span class="line">    remoteip = server.RemoteHostIP</span><br><span class="line">    <span class="keyword">If</span> MsgBox(<span class="string">"request ip:"</span> + remoteip, vbOKCancel) = vbOK <span class="keyword">Then</span></span><br><span class="line">        remoteip.<span class="keyword">Text</span> = remoteip</span><br><span class="line">        <span class="keyword">If</span> server.State &lt;&gt; sckClosed <span class="keyword">Then</span></span><br><span class="line">             server.Close</span><br><span class="line">             server.Accept requestID</span><br><span class="line">        <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'发送文本信息</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> send_Click()</span><br><span class="line"><span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">GoTo</span> errhandle</span><br><span class="line"><span class="keyword">Dim</span> sendtext <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> time <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> record_length <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> msg_length <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> faceid <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> facestart <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line">    time = Format(Now(), <span class="string">"hh:mm:ss"</span>)</span><br><span class="line">    <span class="comment">'format是格式化输出日期和时间格式函数,yyyy-mm-dd是完整显示年月日，hh:mm:ss是显示时分秒。</span></span><br><span class="line">    sendtext = Replace(msg.<span class="keyword">Text</span>, vbCrLf, <span class="string">""</span>)</span><br><span class="line">    sendtext = nickname.<span class="keyword">Text</span> &amp; <span class="string">" "</span> &amp; time &amp; <span class="string">":"</span> &amp; vbCrLf &amp; sendtext &amp; vbCrLf</span><br><span class="line">    record_length = Len(record.<span class="keyword">Text</span>)</span><br><span class="line">    msg_length = Len(sendtext)</span><br><span class="line">    record.SelStart = record_length</span><br><span class="line">    <span class="keyword">Call</span> AddText(record, sendtext, <span class="string">""</span>)</span><br><span class="line">    <span class="keyword">With</span> record</span><br><span class="line">        .SelStart = record_length</span><br><span class="line">        .SelLength = msg_length</span><br><span class="line">        <span class="comment">'Dim font_name, font_size, font_underline, font_strikethru, font_bold, font_italic, font_color</span></span><br><span class="line">        .SelFontName = font_name</span><br><span class="line">        .SelFontSize = font_size</span><br><span class="line">        .SelUnderline = font_underline</span><br><span class="line">        .SelStrikeThru = font_strikethru</span><br><span class="line">        .SelBold = font_bold</span><br><span class="line">        .SelItalic = font_italic</span><br><span class="line">        .SelColor = font_color</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line">    msg.<span class="keyword">Text</span> = <span class="string">""</span></span><br><span class="line">    <span class="comment">'表情图片</span></span><br><span class="line">    facestart = record.Find(<span class="string">"/ali"</span>, record_length)</span><br><span class="line">    <span class="keyword">If</span> facestart &gt; <span class="number">-1</span> <span class="keyword">Then</span></span><br><span class="line">        faceid = <span class="keyword">Mid</span>(record.<span class="keyword">Text</span>, facestart + <span class="number">2</span>, <span class="number">6</span>)</span><br><span class="line">        record.SelStart = facestart</span><br><span class="line">        record.SelLength = <span class="number">7</span></span><br><span class="line">        <span class="keyword">Call</span> facepic(Richtemp, faceid)</span><br><span class="line">        record.SelText = Richtemp.TextRTF</span><br><span class="line">        <span class="keyword">Call</span> rich_backspace(record)</span><br><span class="line">        Richtemp.TextRTF = <span class="string">""</span></span><br><span class="line">        msg.SetFocus</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    record.SelStart = Len(record.<span class="keyword">Text</span>)</span><br><span class="line">    client.SendData sendtext</span><br><span class="line">    <span class="keyword">Exit</span> <span class="keyword">Sub</span></span><br><span class="line">errhandle:</span><br><span class="line">    MsgBox Err.Description</span><br><span class="line">    Request.Enabled = <span class="literal">True</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'server接收数据</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> server_DataArrival(<span class="keyword">ByVal</span> bytesTotal <span class="keyword">As</span> <span class="built_in">Long</span>)</span><br><span class="line"><span class="keyword">Dim</span> receivetext <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> forehwnd <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> facestart <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> faceid <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> record_length <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">Resume</span> <span class="keyword">Next</span></span><br><span class="line">    server.GetData receivetext</span><br><span class="line">    record_length = Len(record.<span class="keyword">Text</span>)</span><br><span class="line">    record.SelStart = record_length</span><br><span class="line">    <span class="keyword">Call</span> AddText(record, receivetext, <span class="string">""</span>)</span><br><span class="line">    facestart = record.Find(<span class="string">"/ali"</span>, record_length)</span><br><span class="line">    <span class="keyword">If</span> facestart &gt; <span class="number">-1</span> <span class="keyword">Then</span></span><br><span class="line">        faceid = <span class="keyword">Mid</span>(record.<span class="keyword">Text</span>, facestart + <span class="number">2</span>, <span class="number">6</span>)</span><br><span class="line">        record.SelStart = facestart</span><br><span class="line">        record.SelLength = <span class="number">7</span></span><br><span class="line">        <span class="keyword">Call</span> facepic(Richtemp, faceid)</span><br><span class="line">        record.SelText = Richtemp.TextRTF</span><br><span class="line">        <span class="keyword">Call</span> rich_backspace(record)</span><br><span class="line">        Richtemp.TextRTF = <span class="string">""</span></span><br><span class="line">        msg.SetFocus</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    record.SelStart = Len(record.<span class="keyword">Text</span>)</span><br><span class="line">    forehwnd = GetForegroundWindow()</span><br><span class="line">    <span class="keyword">If</span> <span class="keyword">Me</span>.hWnd &lt;&gt; forehwnd <span class="keyword">Then</span></span><br><span class="line">        Timer.Enabled = <span class="literal">True</span></span><br><span class="line">        Timer.Interval = <span class="number">1000</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">If</span> min.Value = <span class="number">1</span> <span class="keyword">And</span> newmsgTimer.Enabled = <span class="literal">False</span> <span class="keyword">Then</span></span><br><span class="line">        <span class="keyword">With</span> newmsgTimer</span><br><span class="line">            .Enabled = <span class="literal">True</span></span><br><span class="line">            .Interval = <span class="number">500</span></span><br><span class="line">        <span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> servertimer_Timer()</span><br><span class="line">    StatusBar.Panels(<span class="number">2</span>).<span class="keyword">Text</span> = <span class="string">"Connect Status"</span> &amp; <span class="string">"-"</span> &amp; server.State &amp; client.State &amp; fileserver.State &amp; fileclient.State</span><br><span class="line">    <span class="keyword">If</span> client.State = <span class="number">7</span> <span class="keyword">Or</span> client.State = <span class="number">6</span> <span class="keyword">Or</span> fileclient.State = <span class="number">7</span> <span class="keyword">Or</span> fileclient.State = <span class="number">6</span> <span class="keyword">Then</span></span><br><span class="line">        <span class="keyword">If</span> client.State = <span class="number">7</span> <span class="keyword">And</span> fileclient.State = <span class="number">7</span> <span class="keyword">Then</span></span><br><span class="line">        connect = <span class="literal">False</span></span><br><span class="line">        <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">        Request.Enabled = <span class="literal">False</span></span><br><span class="line">        <span class="keyword">If</span> server.State = <span class="number">7</span> <span class="keyword">And</span> fileserver.State = <span class="number">7</span> <span class="keyword">Then</span></span><br><span class="line">            remoteip.Enabled = <span class="literal">False</span></span><br><span class="line">            nickname.Enabled = <span class="literal">False</span></span><br><span class="line">            StatusBar.Panels(<span class="number">2</span>).<span class="keyword">Text</span> = <span class="string">"Connect OK!"</span> &amp; <span class="string">"-"</span> &amp; server.State &amp; client.State &amp; fileserver.State &amp; fileclient.State</span><br><span class="line">        <span class="keyword">Else</span></span><br><span class="line">            <span class="keyword">If</span> client.State = <span class="number">7</span> <span class="keyword">And</span> fileclient.State = <span class="number">7</span> <span class="keyword">Then</span></span><br><span class="line">                StatusBar.Panels(<span class="number">2</span>).<span class="keyword">Text</span> = <span class="string">"Server Ok!"</span> &amp; <span class="string">"-"</span> &amp; server.State &amp; client.State &amp; fileserver.State &amp; fileclient.State</span><br><span class="line">            <span class="keyword">Else</span></span><br><span class="line">                StatusBar.Panels(<span class="number">2</span>).<span class="keyword">Text</span> = <span class="string">"Connecting!"</span> &amp; <span class="string">"-"</span> &amp; server.State &amp; client.State &amp; fileserver.State &amp; fileclient.State</span><br><span class="line">            <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">        <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">Else</span></span><br><span class="line">        <span class="keyword">If</span> server.State &lt;&gt; <span class="number">2</span> <span class="keyword">And</span> server.State &lt;&gt; <span class="number">7</span> <span class="keyword">And</span> fileserver.State &lt;&gt; <span class="number">2</span> <span class="keyword">And</span> fileserver.State &lt;&gt; <span class="number">7</span> <span class="keyword">Then</span></span><br><span class="line">            server.Close</span><br><span class="line">            server.Listen</span><br><span class="line">            fileserver.Close</span><br><span class="line">            fileserver.Listen</span><br><span class="line">        <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">        <span class="keyword">If</span> connect = <span class="literal">True</span> <span class="keyword">Then</span></span><br><span class="line">            <span class="keyword">If</span> client.State &lt;&gt; <span class="number">6</span> <span class="keyword">Then</span></span><br><span class="line">                <span class="keyword">Call</span> clientconnect</span><br><span class="line">            <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">            <span class="keyword">If</span> fileclient.State &lt;&gt; <span class="number">6</span> <span class="keyword">Then</span></span><br><span class="line">                <span class="keyword">Call</span> fileclientconnect</span><br><span class="line">            <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">            StatusBar.Panels(<span class="number">2</span>).<span class="keyword">Text</span> = <span class="string">"Connect retry!"</span> &amp; <span class="string">"-"</span> &amp; server.State &amp; client.State &amp; fileserver.State &amp; fileclient.State</span><br><span class="line">        <span class="keyword">Else</span></span><br><span class="line">            <span class="keyword">If</span> client.State = <span class="number">8</span> <span class="keyword">Or</span> fileclient.State = <span class="number">8</span> <span class="keyword">Then</span></span><br><span class="line">                client.Close</span><br><span class="line">                fileclient.Close</span><br><span class="line">                server.Close</span><br><span class="line">                fileserver.Close</span><br><span class="line">                Request.Enabled = <span class="literal">True</span></span><br><span class="line">                remoteip.Enabled = <span class="literal">True</span></span><br><span class="line">                nickname.Enabled = <span class="literal">True</span></span><br><span class="line">                StatusBar.Panels(<span class="number">2</span>).<span class="keyword">Text</span> = <span class="string">"Connect Closed!"</span> &amp; <span class="string">"-"</span> &amp; server.State &amp; client.State &amp; fileserver.State &amp; fileclient.State</span><br><span class="line">            <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">        <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">If</span> client.State = sckClosing <span class="keyword">Then</span></span><br><span class="line">        client.Close</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">If</span> server.State = sckClosing <span class="keyword">Then</span></span><br><span class="line">        server.Close</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">If</span> fileclient.State = sckClosing <span class="keyword">Then</span></span><br><span class="line">        fileclient.Close</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">If</span> fileserver.State = sckClosing <span class="keyword">Then</span></span><br><span class="line">        fileserver.Close</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> skin_Click()</span><br><span class="line"><span class="keyword">Dim</span> path <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> skinpath <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line">    skinpath = App.path &amp; <span class="string">"\Data\skin.ini"</span></span><br><span class="line">    <span class="keyword">With</span> CommonDialog1</span><br><span class="line">        .CancelError = <span class="literal">True</span></span><br><span class="line">        .DialogTitle = <span class="string">"Select Skin"</span></span><br><span class="line">        <span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">GoTo</span> cancelerr</span><br><span class="line">        .Filter = <span class="string">"Skin(*.skn)|*.skn"</span></span><br><span class="line">        .InitDir = App.path &amp; <span class="string">"\Data\Skins"</span></span><br><span class="line">        .ShowOpen</span><br><span class="line">        path = .FileName</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line">    Open skinpath <span class="keyword">For</span> Output <span class="keyword">As</span> <span class="meta">#1</span></span><br><span class="line">    Write <span class="meta">#1, path</span></span><br><span class="line">    Close <span class="meta">#1</span></span><br><span class="line">    Skin1.RemoveSkin <span class="keyword">Me</span>.hWnd</span><br><span class="line">    Skin1.LoadSkin path</span><br><span class="line">    Skin1.ApplySkin <span class="keyword">Me</span>.hWnd</span><br><span class="line">cancelerr:</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Timer_Timer()</span><br><span class="line"><span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">Resume</span> <span class="keyword">Next</span></span><br><span class="line">    <span class="keyword">Call</span> FlashWindow(<span class="keyword">Me</span>.hWnd, <span class="literal">True</span>)</span><br><span class="line">    <span class="keyword">If</span> <span class="keyword">Me</span>.WindowState &lt;&gt; vbMinimized <span class="keyword">Then</span></span><br><span class="line">        Timer.Enabled = <span class="literal">False</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> msg_KeyUp(KeyCode <span class="keyword">As</span> <span class="built_in">Integer</span>, Shift <span class="keyword">As</span> <span class="built_in">Integer</span>)</span><br><span class="line"><span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">Resume</span> <span class="keyword">Next</span></span><br><span class="line">    <span class="keyword">If</span> KeyCode = <span class="number">13</span> <span class="keyword">Then</span></span><br><span class="line">        <span class="keyword">Call</span> send_Click</span><br><span class="line">        msg.<span class="keyword">Text</span> = <span class="string">""</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'截图调用</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Command1_Click()</span><br><span class="line"><span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">Resume</span> <span class="keyword">Next</span></span><br><span class="line"><span class="keyword">Dim</span> path <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line">    path = App.path &amp; <span class="string">"\Data\Printscreen.exe"</span></span><br><span class="line">    Shell path</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> fileclient_DataArrival(<span class="keyword">ByVal</span> bytesTotal <span class="keyword">As</span> <span class="built_in">Long</span>)</span><br><span class="line"><span class="keyword">Dim</span> wskcommand <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> cmdarr() <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line"><span class="keyword">Dim</span> filebyte() <span class="keyword">As</span> <span class="built_in">Byte</span></span><br><span class="line"><span class="keyword">If</span> onaccept <span class="keyword">Then</span></span><br><span class="line">    fileclient.GetData filebyte, vbArray + vbByte</span><br><span class="line">    Put <span class="meta">#FileNumber, , filebyte</span></span><br><span class="line">    <span class="comment">'------------进度显示----------</span></span><br><span class="line">    client_VarPlus = client_VarPlus + (UBound(filebyte) + <span class="number">1</span>)</span><br><span class="line">    ReceiveLabel.Caption = <span class="string">"Down:"</span> &amp; Left(Str((client_VarPlus / client_ProBarLen) * <span class="number">100</span>), <span class="number">4</span>) &amp; <span class="string">"%"</span></span><br><span class="line">    <span class="comment">'------------------------------</span></span><br><span class="line">    client_LenFile = client_LenFile - (UBound(filebyte) + <span class="number">1</span>)</span><br><span class="line">    <span class="keyword">If</span> client_LenFile = <span class="number">0</span> <span class="keyword">Then</span></span><br><span class="line">        onaccept = <span class="literal">False</span></span><br><span class="line">        Close <span class="meta">#FileNumber</span></span><br><span class="line">        MsgBox <span class="string">"receive ok!"</span>, vbInformation, <span class="string">"Tips"</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">    <span class="keyword">Exit</span> <span class="keyword">Sub</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">fileclient.GetData wskcommand</span><br><span class="line">cmdarr = Split(wskcommand, <span class="string">","</span>)</span><br><span class="line"><span class="keyword">If</span> cmdarr(<span class="number">0</span>) = <span class="string">"SendFile"</span> <span class="keyword">Then</span></span><br><span class="line">    <span class="keyword">If</span> MsgBox(<span class="string">"Do you want to receive file from remote client?"</span>, vbQuestion + vbYesNo, <span class="string">"File Tips"</span>) = vbYes <span class="keyword">Then</span></span><br><span class="line">    <span class="keyword">With</span> CommonDialog1</span><br><span class="line">        .CancelError = <span class="literal">True</span></span><br><span class="line">        <span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">GoTo</span> saveerr</span><br><span class="line">        .DialogTitle = <span class="string">"Save to..."</span></span><br><span class="line">        .FileName = cmdarr(<span class="number">1</span>)</span><br><span class="line">        .Filter = <span class="string">"All Files(*.*)|*.*"</span></span><br><span class="line">        .Flags = &amp;H4 <span class="keyword">Or</span> &amp;H2</span><br><span class="line">        .ShowSave</span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line">    fileclient.SendData <span class="string">"OkSend"</span></span><br><span class="line">    client_LenFile = Val(cmdarr(<span class="number">2</span>))</span><br><span class="line">    client_ProBarLen = client_LenFile</span><br><span class="line">    client_VarPlus = <span class="number">0</span></span><br><span class="line">    onaccept = <span class="literal">True</span></span><br><span class="line">    FileNumber = FreeFile</span><br><span class="line">    Open CommonDialog1.FileName <span class="keyword">For</span> <span class="keyword">Binary</span> <span class="keyword">As</span> <span class="meta">#FileNumber</span></span><br><span class="line">    <span class="keyword">Else</span></span><br><span class="line">    fileclient.SendData <span class="string">"NoThanks"</span></span><br><span class="line">    <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">Exit</span> <span class="keyword">Sub</span></span><br><span class="line">saveerr:</span><br><span class="line">    fileclient.SendData <span class="string">"NoThanks"</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'文件服务响应连接请求</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> fileserver_ConnectionRequest(<span class="keyword">ByVal</span> requestID <span class="keyword">As</span> <span class="built_in">Long</span>)</span><br><span class="line">    <span class="keyword">If</span> fileserver.State &lt;&gt; sckClosed <span class="keyword">Then</span></span><br><span class="line">        fileserver.Close</span><br><span class="line">        fileserver.Accept requestID</span><br><span class="line">        <span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'文件服务server响应</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> fileserver_DataArrival(<span class="keyword">ByVal</span> bytesTotal <span class="keyword">As</span> <span class="built_in">Long</span>)</span><br><span class="line"><span class="keyword">Dim</span> wskchat <span class="keyword">As</span> <span class="built_in">String</span></span><br><span class="line">fileserver.GetData wskchat</span><br><span class="line"><span class="keyword">If</span> wskchat = <span class="string">"NoThanks"</span> <span class="keyword">Then</span></span><br><span class="line">    MsgBox <span class="string">"Refused"</span>, vbExclamation, <span class="string">"server"</span></span><br><span class="line">    <span class="keyword">ElseIf</span> wskchat = <span class="string">"OkSend"</span> <span class="keyword">Then</span></span><br><span class="line">    MsgBox <span class="string">"accept"</span> &amp; vbCrLf &amp; vbCrLf &amp; <span class="string">"Click OK to receive"</span>, vbInformation, <span class="string">"server"</span></span><br><span class="line">    GetFileNum = FreeFile</span><br><span class="line">    server_LenFile = FileLen(Text1.<span class="keyword">Text</span>)</span><br><span class="line">    server_ProBarLen = server_LenFile</span><br><span class="line">    server_VarPlus = <span class="number">0</span></span><br><span class="line">    Open Text1.<span class="keyword">Text</span> <span class="keyword">For</span> <span class="keyword">Binary</span> <span class="keyword">As</span> <span class="meta">#GetFileNum</span></span><br><span class="line">    onsend = <span class="literal">True</span></span><br><span class="line">    <span class="keyword">Call</span> TCPSendFile(fileserver, GetFileNum, splitfile)</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'文件服务winsock发送完成</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> fileserver_SendComplete()</span><br><span class="line"><span class="keyword">If</span> onsend <span class="keyword">Then</span></span><br><span class="line"><span class="keyword">If</span> <span class="number">0</span> = server_LenFile <span class="keyword">Then</span></span><br><span class="line">    Close <span class="meta">#GetFileNum</span></span><br><span class="line">    onsend = <span class="literal">False</span></span><br><span class="line">    MsgBox <span class="string">"send complete!"</span>, vbInformation, <span class="string">"server"</span></span><br><span class="line">    <span class="keyword">Else</span>: <span class="keyword">Call</span> TCPSendFile(fileserver, GetFileNum, splitfile)</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'文件分割</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Function</span> splitfile() <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">Dim</span> getcount <span class="keyword">As</span> <span class="built_in">Long</span></span><br><span class="line"><span class="keyword">If</span> server_LenFile &gt;= <span class="number">8192</span> <span class="keyword">Then</span></span><br><span class="line">    getcount = <span class="number">8192</span></span><br><span class="line">    server_LenFile = server_LenFile - getcount</span><br><span class="line"><span class="keyword">Else</span></span><br><span class="line">    getcount = server_LenFile</span><br><span class="line">    server_LenFile = server_LenFile - getcount</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line">server_VarPlus = server_VarPlus + getcount</span><br><span class="line">SendLabel.Caption = <span class="string">"Up:"</span> &amp; Left(Str((server_VarPlus / server_ProBarLen) * <span class="number">100</span>), <span class="number">4</span>) &amp; <span class="string">"%"</span></span><br><span class="line">splitfile = getcount</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Function</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'发送文件</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> TCPSendFile(objWinSock <span class="keyword">As</span> Winsock, FileNumber <span class="keyword">As</span> <span class="built_in">Integer</span>, SendLen <span class="keyword">As</span> <span class="built_in">Long</span>)</span><br><span class="line">    <span class="keyword">Dim</span> filebyte() <span class="keyword">As</span> <span class="built_in">Byte</span></span><br><span class="line">    <span class="keyword">ReDim</span> filebyte(SendLen - <span class="number">1</span>)</span><br><span class="line">    <span class="keyword">Get</span> <span class="meta">#FileNumber, , filebyte</span></span><br><span class="line">    objWinSock.SendData filebyte</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br><span class="line"></span><br><span class="line"><span class="comment">'请求发送</span></span><br><span class="line"><span class="keyword">Private</span> <span class="keyword">Sub</span> Command2_Click()</span><br><span class="line"><span class="keyword">With</span> CommonDialog1</span><br><span class="line">    .CancelError = <span class="literal">True</span></span><br><span class="line">    <span class="keyword">On</span> <span class="keyword">Error</span> <span class="keyword">GoTo</span> openerr</span><br><span class="line">    .DialogTitle = <span class="string">"Open"</span></span><br><span class="line">    .Filter = <span class="string">"All Files(*.*)|*.*"</span></span><br><span class="line">    .Flags = &amp;H4</span><br><span class="line">    .InitDir = App.path</span><br><span class="line">    .ShowOpen</span><br><span class="line">    Text1.<span class="keyword">Text</span> = .FileName</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">With</span></span><br><span class="line">fileserver.SendData <span class="string">"SendFile,"</span> &amp; Dir(Text1.<span class="keyword">Text</span>) &amp; <span class="string">","</span> &amp; FileLen(Text1.<span class="keyword">Text</span>)</span><br><span class="line">openerr:</span><br><span class="line"><span class="keyword">If</span> Err.Number = <span class="number">32755</span> <span class="keyword">Or</span> Err.Number = <span class="number">0</span> <span class="keyword">Then</span></span><br><span class="line"><span class="keyword">Exit</span> <span class="keyword">Sub</span></span><br><span class="line"><span class="keyword">Else</span></span><br><span class="line">MsgBox Err.Description &amp; Err.Number</span><br><span class="line"><span class="keyword">End</span> <span class="keyword">If</span></span><br><span class="line"><span class="keyword">End</span> <span class="keyword">Sub</span></span><br></pre></td></tr></table></figure>


      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>Donate</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wx.jpg" alt="tosobright WeChat Pay">
        <p>WeChat Pay</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/ali.jpg" alt="tosobright Alipay">
        <p>Alipay</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>Post author:</strong>
    tosobright
  </li>
  <li class="post-copyright-link">
    <strong>Post link:</strong>
    <a href="http://www.soshare.cn/2012/06/12/120612-vb-chat/" title="VB聊天工具">http://www.soshare.cn/2012/06/12/120612-vb-chat/</a>
  </li>
  <li class="post-copyright-license">
    <strong>Copyright Notice: </strong>
    All articles in this blog are licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> unless stating additionally.
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/vb/" rel="tag"><i class="fa fa-tag"></i> vb</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2012/03/11/120311-labview-reentrant/" rel="next" title="LabVIEW可重入">
                <i class="fa fa-chevron-left"></i> LabVIEW可重入
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2012/06/15/120615-vb-comm/" rel="prev" title="vb-串口程序">
                vb-串口程序 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        
  <div class="bdsharebuttonbox">
    <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
    <a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a>
    <a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
    <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
    <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
    <a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a>
    <a href="#" class="bds_twi" data-cmd="twi" title="分享到Twitter"></a>
    <a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
    <a href="#" class="bds_more" data-cmd="more"></a>
    <a class="bds_count" data-cmd="count"></a>
  </div>
  <script>
    window._bd_share_config = {
      "common": {
        "bdText": "",
        "bdMini": "2",
        "bdMiniList": false,
        "bdPic": ""
      },
      "share": {
        "bdSize": "16",
        "bdStyle": "0"
      },
      "image": {
        "viewList": ["tsina", "douban", "sqq", "qzone", "weixin", "twi", "fbook"],
        "viewText": "分享到：",
        "viewSize": "16"
      }
    }
  </script>

<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='//bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

      
      <script data-ad-client="ca-pub-3578624407535320" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.jpg" alt="tosobright">
            
              <p class="site-author-name" itemprop="name">tosobright</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">51</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                
                  <span class="site-state-item-count">4</span>
                  <span class="site-state-item-name">categories</span>
                
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">26</span>
                  <span class="site-state-item-name">tags</span>
                
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/tosobright" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i></a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://gitee.com/tosobright" target="_blank" title="Gitee">
                      
                        <i class="fa fa-fw fa-git"></i></a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:tosobright@gmail.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i></a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:toso@soshare.cn" target="_blank" title="E-Mail2">
                      
                        <i class="fa fa-fw fa-envelope-square"></i></a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.soshare.cn/" title="Soshare" target="_blank">Soshare</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#介绍"><span class="nav-number">1.</span> <span class="nav-text">介绍</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#代码"><span class="nav-number">2.</span> <span class="nav-text">代码</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2010 &mdash; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">tosobright</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







  <div style>
    <script src="//s95.cnzz.com/z_stat.php?id=1726916&web_id=1726916" language="JavaScript"></script>
  </div>



        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: true,
        notify: true,
        appId: 'TMSskYT1d5742mMn1W68iohd-gzGzoHsz',
        appKey: 'dIOnzLoKHUh71UF48oH6r0Qe',
        placeholder: 'Just go go',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("TMSskYT1d5742mMn1W68iohd-gzGzoHsz", "dIOnzLoKHUh71UF48oH6r0Qe");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  

  
  


  
  <script type="text/javascript" src="/js/src/js.cookie.js?v=5.1.4"></script>
  <script type="text/javascript" src="/js/src/scroll-cookie.js?v=5.1.4"></script>


  

</body>
</html>
